package com.hamizhong.iflowers.common.logger;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.LogManager;
import org.apache.log4j.xml.DOMConfigurator;

public class MyLoggerFactory {

	private static boolean junitLoggerSwitch = false;
	
	public static MyLogger getLogger(Class className) {
		return new MyLogger(LogManager.getLogger(className));
	}
	
	public static MyLogger getLoggerForJunit(Class className) {
		if(!junitLoggerSwitch) {
			loadConfig();
		}
		return new MyLogger(LogManager.getLogger(className));
	}

	private static void loadConfig() {
		try {
			DOMConfigurator.configure(MyLoggerFactory.class.getResource("com/hamizhong/iflowers/resource/log4j.xml"));
		} catch (Exception e) {
			BasicConfigurator.configure();
		}
	}
}
